home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir39 / cmddat10.zip / CMDDATE.DOC < prev   
Text File  |  1993-04-15  |  13KB  |  243 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                            Command-Date Version 1.0
  9.  
  10.                                   RebelWare
  11.                                Ronnie E. Belvin
  12.                                Rt. 2 Box 210-A
  13.                               Decatur, Ms. 39327
  14.                                 (601)635-3597
  15.                                 CIS 75260,1670
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.         Command-Date is a dos utility program that can be used to
  26. selectively execute dos commands on files selected by date. Command-Date
  27. searches for files that match the required file path/specification.
  28. When a matching filespec is found, Command-Date compares the file's
  29. date with the required date. If the files date is within the range
  30. specified, Command-Date spawns command.com with the instruction to
  31. execute the desired dos command. Command-Date passes the file name of
  32. the matching file to the dos command as it's first parameter. This file
  33. will be the target of the dos command. Upon completion of the dos
  34. command, control is returned to Command-Date and the process is repeated
  35. until the search criteria is exhausted.
  36.         Command-Date will execute any dos executable file, .com, .exe,
  37. .bat, internal or external, that will accept a file name as its first
  38. command line parameter. Actually Command-Date will attempt to execute
  39. ANY executable, once for each file that matches the search criteria, but
  40. for it to be useful the dos executable must accept a filename as it's
  41. first parameter and it must return control to the system when it's
  42. finished it's task.
  43.         Command-Date will also pass any number of parameters to the
  44. executable as it's second or greater parameter. This enables
  45. Command-Date to work with dos commands that require multiple parameters,
  46. such as Copy and Rename. The first parameter passed to the executable
  47. will always be the fully qualified file name of the matching file.
  48.  
  49.         The execution can be aborted at any time by pressing any key on
  50. the keyboard except pause. The pause key will halt execution until any
  51. other key is pressed. If the confirmation switch is used, pressing any
  52. key will not abort the program. To abort in confirmation mode, first
  53. select continue, then press any key.
  54.         Typing the program name with no parameters or with incorrect
  55. parameters will display a brief help screen. The help screen is a
  56. summary of this document and is included for a quick reference. The
  57. essential parameters are closely checked for errors and either an
  58. error message or the help screen will be displayed if an error is
  59. found. Other parameters such as the command name and the additional
  60. parameter fields have been left "loose". Command-Date simply checks for
  61. their existence and inserts them directly into the executable command
  62. line. This was done for versatility and it's up to you to determine the
  63. correct parameters for these fields.
  64.  
  65. The correct command line usage of Command-Date is as follows:
  66.  
  67. Cmddate Command Filespec [Para] @+||-[Offset] [Date] [/Switch]
  68.  
  69. Command  - Dos Command To Be Executed
  70. Filespec - Path And Filename Of Files To Be Operated Upon, Wildcards Are Ok
  71. Para     - Additional Parameters That Will Be Passed Directly To Command
  72. @+Offset - Command Will Operate Upon All Files > (Date + Offset)
  73. @-Offset - Command Will Operate Upon All Files < (Date - Offset)
  74. Offset   - Number Of Days To Be Added OR Subtracted From The Date
  75. Date     - Date In The Form MM/DD/YY OR MM-DD-YY
  76. /Switch  - /T = Test Mode, Only Prints Commands
  77.            /S = Include Sub Directories
  78.            /C = Confirm Each Command Before Execution
  79.            /N = Answer No To Prompts
  80.  
  81. ALL PARAMETERS MUST BE SEPARATED BY A SPACE.
  82.  
  83.         The Command in the command line is the name of the dos
  84. executable to be executed. This file should be in the current directory,
  85. in the path, or the full path name can be entered. The Filespec is the
  86. path and filename that Command-Date will use as the search criteria. Dos
  87. Wildcards are acceptable here and should be used the same as you would
  88. use them with any dos command.
  89.         The Para parameters are optional to Command-Date, they are not
  90. optional to some executable. If the executable you want to use
  91. requires more than one parameter, enter then here. Any number of
  92. additional parameters may entered between the Filespec and the @+ or @-
  93. parameters and these will be passed directly to the executable as it's
  94. second, third, fourth, ect. parameters. Copy and Rename are examples of
  95. dos commands that require two parameters.
  96.         The @+ tells Command-Date to search for files whose file date is
  97. greater than the Date parameter. The @- tells Command-Date to search for
  98. files whose file date is less than the Date parameter. Command-Date uses
  99. true greater than (>) or less than (<) comparison, not greater than or
  100. equal to (>=), or less than or equal to (<=).
  101.         The Offset is optional and is used differently depending on
  102. whether or not a Date parameter is entered. If the Date is not entered
  103. the Offset must be used.If the Date is entered the offset may or may not
  104. be used, depending on the mode of operation desired. It is always a number
  105. of days that is added (@+) or subtracted (@-) from the Date.
  106.         The Date is the date on which comparisons will be made. It is
  107. also optional depending on the desired mode. When the Date parameter is
  108. used it should be in the form mm/dd/yy or mm-dd-yy.
  109.         Four switches are available. Both should be preceded by a "/"
  110. and separated by spaces. The /T is the test mode. This switch causes
  111. Command-Date to only display the commands that would have otherwise been
  112. executed. This enables you to make sure that you have the command line
  113. parameters correct before actually executing a Command-Date. The /S
  114. switch causes Command-Date to include all sub-directories in it's search.
  115. This is a powerful and hazardous switch. With it you can do global hard
  116. drive deletes, copies, renames, ect. Use it with caution. Always use the
  117. /T switch first to confirm that your parameter are all correct. The /C
  118. switch causes Command-Date to Confirm all operations before executing
  119. each command. The command will be displayed and you will be asked if
  120. you want to execute this command. You may answer Y, N, or C. Yes will
  121. cause the command to be executed, no will cause the command to be
  122. skipped, and continue will cause Command-Date to leave the confirmation
  123. mode and continue executing the command on the remainder of the files
  124. that match the search criteria. The /N switch causes Command-Date to
  125. to answer no to prompts from the executed command. It is intended to
  126. be used with programs that ask if you want to process more files at
  127. the end of their execution. One such program is dos's compare (comp).
  128. Actually the "N" and a carriage return is stuffed into the keyboard
  129. buffer before the command is executed and will answer no to the next
  130. keyboard read. This switch requires an AT computer with an extended
  131. (101) keyboard. The XT bios does not support the bios calls used to
  132. implement this switch.
  133.  
  134.  
  135.  
  136. DATE AND OFFSET COMBINATIONS:
  137.  
  138. Omitting Both Date AND Offset Is NOT valid. Offset of zero is Not valid
  139.  
  140. Date with no Offset:
  141. Operates upon files (greater than) or (less than) the Date.
  142. Entering A Date With No Offset Will Cause The Command To Be Executed
  143.    Once For Each File That Is (@+) > OR (@-) < The Date.
  144.  
  145. Offset with no Date:
  146. Operates upon files (greater than) or (less than) the (system date plus
  147. or minus the Offset).
  148. Entering An Offset With No Date Will Cause The Command To Be Executed Once
  149.    For Each File That Is (@+) > The System Date Plus The Offset, OR
  150.    For Each File That Is (@-) < The System Date Minus The Offset.
  151.  
  152. Date and Offset:
  153. Operates upon files whose file date fall between the Date and The Date
  154. plus the Offset, or the Date and the Date minus the Offset.
  155. Entering A Date And An Offset Will Cause The Command To Be Executed Once
  156.    For Each File That Is (@+) > The Date AND < The Date Plus Offset, OR
  157.    For Each File That Is (@-) < The Date AND > The Date Minus Offset.
  158.  
  159.  
  160. Examples:
  161. Cmddate DEL C:\*.DOC @+ 3/15/93   Deletes *.DOC > 3/15/93
  162. Cmddate DEL C:\*.PRN @- 3/15/93   Deletes *.PRN < 3/15/93
  163. Cmddate DEL C:\*.BAK @-5          Deletes *.BAK < System Date Minus 5
  164. Cmddate DEL C:\*.TXT @-5 3/15/93  Deletes *.TXT < 3/15/93 AND > 3/10/93
  165. Cmddate DEL c:\*.SYS @+5 3/15/93  Deletes *.SYS > 3/15/93 AND < 3/20/93
  166. Cmddate COPY *.* C:\DIR @+ 3/15/93 Copies All Files With Dates > 3/15/93
  167.    To C:\DIR\
  168. Cmddate REN *.TXT *.BAK @+5 3/15/93 Renames All *.TXT With Dates
  169.    > 3/15/93 AND < 3/20/93 To *.BAK
  170.  
  171. Limitations:
  172.  
  173. Command-Date has several limitations. The 128 character command line
  174. length imposed by dos limits the length of the Command-Date command
  175. line. That same limitation limits the length of the command line that
  176. Command-Date can issue to dos in executing a command. Some of the
  177. functions of the Borland C compiler that was used has a maximum path
  178. of 80 characters. Command-date uses these function to build file paths,
  179. so the file specs that Command-Date passes to the Command as the first
  180. parameter cannot exceed 80 characters. This could be a problem on hard
  181. drives with lots of long subdirectory names.
  182.         When using the include subdirectories option, Command-Date
  183. stores pending subdirectory paths on a last-in first-out, dynamically
  184. allocated memory stack. It is limited to a maximum of 500 entries,
  185. with a maximum of 80 characters in length. This should handle most hard
  186. drives with no problem.
  187.         Valid dates are from 1-1-81 to 12-31-99. These limits are
  188. imposed on the sum of the date and the offset. Entering a date and
  189. offset combination that results in a test date outside these limits
  190. will give a date out of range error.
  191.         The /N requires an AT computer with a extended (101) keyboard.
  192. It will not work on an XT computer because the bios calls used to write
  193. to the keyboard are not supported by the XT bios or by 84 key keyboards.
  194.  
  195. Dos commands known to work with Command-Date:
  196.  
  197. Del     use normal single parameter with wildcards.
  198. Dir     use normal single parameter with wildcards, use /T to get better listing
  199. Copy    use normal source and destination parameters with wildcards.
  200. Ren     use normal current filename and new filename parameters with wildcards.
  201. Comp    use Command-Date's /N switch to answer no to the more files? prompt.
  202. Backup  use Backup's /A switch to append files of a selected date.
  203.  
  204. use the /S switch with all the above to include all subdirectories.
  205.  
  206. Purpose and Usefulness:
  207.  
  208.         The reason for writing this program was simply because I
  209. needed a utility to delete all files with a specific extension that were
  210. over three days old. These files were being downloaded daily from a
  211. mainframe host into many subdirectories on a network drive. The
  212. files were updated regularly on the host and the operators were supposed
  213. to delete the local files each time they were used , to assure
  214. that we were always using up to date files. Often files didn't get
  215. deleted and after a few weeks hundreds of out of date files would
  216. accumulate. It was very time consuming to delete these files
  217. individually. Some disk utilities helped but it was still a slow
  218. process. I could not find any utilities that would help with this
  219. problem. No one but me seemed to be concerned with file dates so I
  220. decided to do it myself.
  221.         While writing I decided not to restrict it's usage, just to
  222. deletion. I tried to make it as versatile as possible. Although A large
  223. part of the code is devoted to command line interpretation and
  224. validation, any executable file can be entered for the Command and any
  225. number of parameters can be passed directly to that command as second,
  226. third, ect parameters. The include subdirectory option by itself is a
  227. useful extension to the delete, rename, and copy commands. By setting
  228. the date selection to less than tomorrow and invoking the /S option,
  229. these dos commands can be used to globally delete, rename, or copy
  230. entire hard drives with one command.
  231.         There are probably many executable files that will be useful when
  232. run with Command-Date. Feel free to Use it, experiment with it, and
  233. share it with your friends. I spent many hours on this program (I am
  234. an amateur programmer and this is my first "C" program of any
  235. significance) and I had rather see it used than just taking up disk
  236. space. I'd be interested in knowing if anyone finds any bugs, has any
  237. suggestions for improvements, is using it in any unusual applications,
  238. or has found any useful executable to be ran with Command-Date. I can
  239. be contacted at my home phone or address, or through electronic mail on
  240. compuserv. My address, phone, and compuserv id are listed at the beginning
  241. of this document. I hope that this program will make someone else's hard
  242. drive maintenance a little easer.
  243.